/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.unipar.cursoweb.modelo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

/**
 *
 * @author Thiago Marques
 */
@Entity
public class Servico implements Serializable{
    
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Long idServico;
    private String nome;
    private BigDecimal valor;
    private Boolean ativo;
    @Temporal(TemporalType.DATE)
    private Date dtCadastro;
    @Version
    private Timestamp versao;
     @OneToMany(cascade= CascadeType.MERGE, 
             fetch= FetchType.LAZY,
            mappedBy="servico", 
            targetEntity=ItensOrdemServico.class,
            orphanRemoval=true)
    private List<ItensOrdemServico> itensOrdemServico = 
            new ArrayList<ItensOrdemServico>();

    public Boolean getAtivo() {
        return ativo;
    }

    public void setAtivo(Boolean ativo) {
        this.ativo = ativo;
    }

    public Date getDtCadastro() {
        return dtCadastro;
    }

    public void setDtCadastro(Date dtCadastro) {
        this.dtCadastro = dtCadastro;
    }

    public Long getIdServico() {
        return idServico;
    }

    public void setIdServico(Long idServico) {
        this.idServico = idServico;
    }

    public List<ItensOrdemServico> getItensOrdemServico() {
        return itensOrdemServico;
    }

    public void setItensOrdemServico(List<ItensOrdemServico> itensOrdemServico) {
        this.itensOrdemServico = itensOrdemServico;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public BigDecimal getValor() {
        return valor;
    }

    public void setValor(BigDecimal valor) {
        this.valor = valor;
    }

    public Timestamp getVersao() {
        return versao;
    }

    public void setVersao(Timestamp versao) {
        this.versao = versao;
    }
    
}
